package com.cskaoyan.demo;

import com.cskaoyan.Account;
import com.cskaoyan.MyResultSetHandler;
import com.cskaoyan.utils.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;

import java.lang.reflect.Method;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import java.util.logging.Handler;

public class QueryRunnerDemo1 {

    public static void main(String[] args) throws SQLException {

        // 如何使用QueryRunner呢？
        QueryRunner queryRunner = new QueryRunner();

        // 获取连接
        Connection connection = DruidUtils.getConnection();

        // 执行SQL语句，并且返回结果集
        List<Account> accountList = (List<Account>)queryRunner.query(connection, "select * from account", new MyResultSetHandler());

//        MyResultSetHandler myResultSetHandler = new MyResultSetHandler();
//        Class<? extends MyResultSetHandler> clazz = myResultSetHandler.getClass();
//
//        Method[] methods = clazz.getMethods();
//
//        Method methods1 = methods[0];
//
//        methods1.invoke()


        System.out.println(accountList);

    }


}
